import request from '@/utils/request'

// 获取碳信用统计数据
export function getCarbonCreditAssetsTotal() {
  return request({
    url: '/assets/carbonCreditAssets/assetsTotal',
    method: 'get'
  })
}

// 获取交易所数据
export function getCarbonExchangePageList(data) {
  return request({
    url: '/assets/carbonExchange/getPageList',
    method: 'post',
    data
  })
}

// 获取碳信用分页列表
export function loadCarbonCreditPageList(data) {
  return request({
    url: '/assets/carbonCreditAssets/getPageList',
    method: 'post',
    data
  })
}

// 获取项目库数据
export function getCarbonMetaregistryPageList(data) {
  return request({
    url: '/assets/carbonMetaregistry/getPageList',
    method: 'post',
    data
  })
}

// 文件上传
export function uploadCredential(file) {
  const formData = new FormData()
  formData.append('file', file)
  return request({
    url: '/assets/exchangeAccount/uploadCredential',
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

// 添加碳信用项目
export function addCarbonCredit(data) {
  return request({
    url: '/assets/carbonCreditAssets/add',
    method: 'post',
    data
  })
}

// 添加碳配额项目
export function addCarbonQuota(data) {
  return request({
    url: '/assets/carbonQuotaAssets/add',
    method: 'post',
    data
  })
}

// 修改碳信用
export function changeCredit(data) {
  return request({
    url: '/assets/carbonCreditAssets/update',
    method: 'put',
    data
  })
}

// 修改碳配额
export function changeQuota(data) {
  return request({
    url: '/assets/carbonQuotaAssets/update',
    method: 'put',
    data
  })
}

// 删除碳信用
export function deleteCarbonCredit(id) {
  return request({
    url: '/assets/carbonCreditAssets/delete',
    method: 'post',
    data: { id }
  })
}

// 获取碳信用详情
export function carbonAssetDetail(id) {
  return request({
    url: `/assets/carbonCreditAssets/info/${id}`,
    method: 'get'
  })
}

// 获取交易所列表
export function loadCarbonExchangeList(data) {
  return request({
    url: '/assets/carbonExchange/getPageList',
    method: 'post',
    data
  })
}

// 搜索交易所
export function searchCarbonExchanger(data) {
  return request({
    url: '/assets/carbonExchange/search',
    method: 'post',
    data
  })
}

// 添加采购记录
export function addCarbonTradeQuote(data) {
  return request({
    url: '/trade/carbonTradeQuote/add',
    method: 'post',
    data
  })
}

// 添加场外上架记录
export function addcarbonAssetMarket(data) {
  return request({
    url: '/trade/carbonAssetMarket/add',
    method: 'post',
    data
  })
}

// 获取方法学列表
export function loadMethodList(data) {
  return request({
    url: '/assets/carbonMethodology/getPageList',
    method: 'post',
    data
  })
}

// 获取方法学详情
export function readMethod(id) {
  return request({
    url: `/assets/carbonMethodology/info/${id}`,
    method: 'get'
  })
}

// 获取碳项目列表
export function getCarbonProjectPageList(data) {
  return request({
    url: '/assets/carbonProject/getPageList',
    method: 'post',
    data
  })
}

// 碳配额相关API
// 获取碳配额分页列表
export function loadCarbonQuotaPageList(query) {
  return request({
    url: '/assets/carbonQuotaAssets/getPageList',
    method: 'post',
    data: query
  })
}

// 获取碳配额统计数据
export function getQuotaData() {
  return request({
    url: '/assets/carbonQuotaAssets/assetsTotal',
    method: 'get'
  })
}

// 获取碳配额详情
export function carbonQuotaDetail(id) {
  return request({
    url: `/assets/carbonQuotaAssets/info/${id}`,
    method: 'get'
  })
}

// 开发立项相关API

// 获取开发立项详情
export function readCarbonProject(id) {
  return request({
    url: `/assets/carbonProject/info/${id}`,
    method: 'get'
  })
}

// 创建开发立项项目
export function createCarbonProject(data) {
  return request({
    url: '/assets/carbonProject/add',
    method: 'post',
    data
  })
}

// 修改开发立项项目
export function editCarbonProject(data) {
  return request({
    url: '/assets/carbonProject/update',
    method: 'put',
    data
  })
}

// 删除开发立项项目
export function deleteCarbonProject(id) {
  return request({
    url: `/assets/carbonProject/delete/${id}`,
    method: 'delete'
  })
}

// 获取城市字典
export function getCityDict() {
  return request({
    url: '/system/dict/data/type/city',
    method: 'get'
  })
}

// 项目文档管理相关API
// 获取项目文档分页列表
export function loadcarbonProjectDoc(data) {
  return request({
    url: '/assets/carbonMetaregistryDoc/getPageList',
    method: 'post',
    data
  })
}

// 添加项目文档
export function addCarbonProjectFile(data) {
  return request({
    url: '/assets/carbonProjectDoc/add',
    method: 'post',
    data
  })
}

// 供需行情相关API
// 获取碳交易报价列表
export function getCarbonTradeQuoteList(data) {
  return request({
    url: '/trade/carbonTradeQuote/getPageList',
    method: 'post',
    data
  })
}

// 添加采购行情
export function pushQuote(data) {
  return request({
    url: '/trade/carbonTradeQuote/add',
    method: 'post',
    data
  })
}

// 开始交易（报价/询价）
export function startTrading(data) {
  return request({
    url: '/trade/carbonTradeQuote/startTrading',
    method: 'post',
    data
  })
}

// 搜索关键字
export function searchKeyword(data) {
  return request({
    url: '/trade/carbonTradeQuote/search',
    method: 'post',
    data
  })
}

// 询报价管理相关API
// 获取询报价数据列表（临时使用供需行情API）
export function getCarbonTradePriceList(data) {
  return request({
    url: '/trade/carbonTradeQuote/getPageList',
    method: 'post',
    data
  })
}

// 获取询报价详情（临时使用供需行情API）
export function getCarbonTradePerfenceDetail(id) {
  return request({
    url: `/trade/carbonTradeQuote/info/${id}`,
    method: 'get'
  })
}

// 意向成交提交（临时使用供需行情API）
export function intendedTransaction(data) {
  return request({
    url: '/trade/carbonTradeQuote/startTrading',
    method: 'post',
    data
  })
}

// 系统项目库管理相关API
// 获取项目库数据（按关键字搜索）
export function getEscarbonMetaregistryList(data) {
  return request({
    url: '/assets/EscarbonMetaregistry/getByKeyword',
    method: 'post',
    data
  })
}

// 获取项目库数据（标准列表）
export function getCarbonMetaregistryList(data) {
  return request({
    url: '/assets/carbonMetaregistry/getPageList',
    method: 'post',
    data
  })
}